package com.md.youyouhui.net;

import android.content.Context;

import com.google.gson.Gson;
import com.md.youyouhui.utils.calladapter.LiveDataCallAdapterFactory;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author AdministratorZJ
 */
public class ApiServiceFac {

    private static ApiService mApiService;
    private ApiServiceFac(Context context) {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(NetWorkConstant.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create(new Gson()))
                .addCallAdapterFactory(new LiveDataCallAdapterFactory())
                .client(OkHttpUtils.newInstance(context).build())
                .build();
        mApiService = retrofit.create(ApiService.class);
    }

    public static ApiService get() {
        return mApiService;
    }

    public static ApiServiceFac init(Context context) {
        return new ApiServiceFac(context);
    }


    /**
     * 获取天气
     * @return
     */
    /*public Call<WeatherBean> getWeather() {
        return mRequestInterface.getWeathers("https://api.seniverse.com/v3/weather/now.json?key=jvmhmvicxdqjfx71&location=hangzhou&language=zh-Hans&unit=c"
                , "zj");
    }*/
    /**
     * 登录
     * @return
     */
    /*public Call<Result<LoginResponse>> login(LoginHead head) {
        return mRequestInterface.login(head.getTel(),head.getPwd());
    }*/
}
